package jaux.tank.generator.domain;

import java.util.List;
import java.util.UUID;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
public class TankEntityRelationship {

	public enum RelationshipType{
		ONE_TO_MANY , MANY_TO_ONE , ONE_TO_ONE , MANY_TO_MANY
	}
	public enum PointerCascade{
		ALL, DETACH, PERSIST, REMOVE, REFRESH, MERGE
	}
	
	private RelationshipType type;
	
	private String name;
	
	private String comment;
	
	private String id;
	
	private Pointer from;
	
	private Pointer to;
	
	public TankEntityRelationship() {
		this("");
		
	}
	public TankEntityRelationship(String name) {
		this.id = UUID.randomUUID().toString();
		this.name = name;
		this.type = RelationshipType.ONE_TO_MANY;
		this.from = new Pointer();
		this.to = new Pointer();
		
	}

	@Data
	@NoArgsConstructor
	public static class Pointer{
		
		private List<PointerCascade> cascades;
		
		private String entity;
		private String relationName;
		private String displayField;
		
		private String comment;
		
		private boolean required;
		
		private boolean builtInEntity;
	}
}
